<?php
/**
 * 
 * @author Paolo Bertuzzo
 *
 */
namespace Utilities\Server;

class Url
{
    /**
     * 
     * @return string
     */
    public static function getCurrentUrl() 
    {
    	$s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : "";
    	$protocol = substr(strtolower($_SERVER["SERVER_PROTOCOL"]), 0, strpos(strtolower($_SERVER["SERVER_PROTOCOL"]), "/")) . $s;
    	$port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
    	$uri = $protocol . "://" . $_SERVER['SERVER_NAME'] . $port . $_SERVER['REQUEST_URI'];
    	$segments = explode('?', $uri, 2);
    	$url = $segments[0];
    	
    	return $url;
    }
    
}

?>